<!-- Main content -->
@extends('layouts.default')
@section('css')
    <link rel="stylesheet" href="{{asset('admin-lte/plugins/datatables/dataTables.bootstrap4.css')}}">
    {{--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">--}}
    <style>
        .help-block-error{
            color:red;
        }
        table th,table td{
            font-size:14px!important;
        }
    </style>
@stop

@section('content')
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">合伙人管理 / <a class="text-primary" href="{{url('admin/copartner/apply')}}">合伙人申请</a></h3>
                </div>

                <div class="card-body">
                    <div class="card-body">
                        @include('layouts.message')
                        <div class="col-md-12" style="margin-bottom:20px">
                            <span style="font-weight: bold;">所有人总充值金额</span>: <input style="color:blue;text-align: center" type="text" value="{{ $total_recharge}}" disabled>
                        </div>

                        <table id="example1" class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>操作</th>
                                    <th>平台账号</th>
                                    <th>姓名</th>
                                    <th>电话</th>
                                    <th>身份证号</th>
                                    <th>店铺名称</th>
                                    <th>店铺地址</th>
                                    <th>申请时间</th>
                                    <th>总充值金额</th>
                                </tr>
                            </thead>
                            <tbody>
                            @foreach ($list as $v)
                                <tr>
                                    <td>
                                        @if($v['status'] == 1)
                                            <span style="color:blue">已同意</span>
                                        @elseif($v['status'] == 2)
                                            <button class="btn btn-sm btn-success">已拒绝</button>
                                        @else
                                            <button class="btn btn-sm btn-success pass_apply" data-url="{{url('admin/copartner/doapply',['id'=>$v['id'],'status'=>1])}}">同意</button>
                                            <button class="btn btn-sm btn-danger reject_apply" data-url="{{url('admin/copartner/doapply',['id'=>$v['id'],'status'=>2])}}">拒绝</button>
                                        @endif

                                    </td>
                                    <td>{{ $v['user_name'] }}</td>
                                    <td>{{ $v['true_name'] }}</td>
                                    <td>{{ $v['phone'] }}</td>
                                    <td>
                                        {{ $v['idcardnum'] }}
                                    </td>
                                    <td>{{ $v['shop_name'] }}</td>
                                    <td>{{ $v['shop_address'] }}</td>
                                    <td>{{ $v['created_at'] }}</td>
                                    <td>{{ $v['total_recharge']}}</td>
                                </tr>
                            @endforeach
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="9"></td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

@stop



@section('script')
    <script src="{{asset('admin-lte/plugins/datatables/jquery.dataTables.js')}}"></script>
    <script src="{{asset('admin-lte/plugins/datatables/dataTables.bootstrap4.js')}}"></script>

    {{--layer插件--}}
    <script src='{{asset("admin-lte/plugins/layer-v3.1.1/layer.js")}}' type="text/javascript"></script>
    <script>
        $("#example1").DataTable({
            "language"  : {
                url :'https://cdn.datatables.net/plug-ins/1.10.19/i18n/Chinese.json'
            },
            buttons: [
                {
                    text: 'Alert',
                    action: function ( e, dt, node, config ) {
                        alert( 'Activated!' );
                        this.disable(); // disable button
                    }
                }
            ]
        });

        $('.pass_apply').on('click',function(){
            var href = $(this).data('url');
            layer.confirm('确认要同意申请吗?',function(){
                location.href = href;
            })
        })

        $('.reject_apply').on('click',function(){
            var href = $(this).data('url');
            layer.confirm('确认要拒绝申请吗?',function(){
                location.href = href;
            })
        })
    </script>
@stop
